import request from '@/utils/request'

// 用户相关 API
export const userAPI = {
  // 获取用户信息
  getUserInfo() {
    return request.get('/user/info')
  },

  // 更新用户信息
  updateUserInfo(userInfo) {
    return request.put('/user/info', userInfo)
  },

  // 修改密码
  changePassword(oldPassword, newPassword) {
    return request.put('/user/password', { oldPassword, newPassword })
  },

  // 修改手机号
  changePhone(phone, code) {
    return request.put('/user/phone', { phone, code })
  },

  // 获取用户套餐信息
  getUserPackage() {
    return request.get('/user/package')
  },

  // 获取购买记录
  getPurchaseHistory() {
    return request.get('/user/purchase-history')
  },

  // 上传头像
  uploadAvatar(file) {
    const formData = new FormData()
    formData.append('file', file)
    return request.post('/user/avatar', formData, {
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  }
}


